<?php
require_once('config.php');
class MySQLDB {
	
	private $con;
	
	function __construct(){
		$this->connect();
	}
		
	public function connect(){
		$this->con = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
		if(!$this->con){
			die('Database Connection Failed!' . mysql_error());
		}else{
			mysql_select_db(DB_NAME,$this->con);
		}
	}
	
	public function query($sql){
		return mysql_query($sql);
	}
	
	public function fetch_array($query){
		return mysql_fetch_array($query);
	}
	
	public function num_rows($query){
		return mysql_num_rows($query);
	}
	
	public function close_connection(){
		if(isset($this->con)) {
			mysql_close($this->con);
			unset($this->con);
		}
	}
}

 $db = new MySQLDB();

?>